<div class="profile-content-row">
	<?php if(!empty($comments)){
		foreach($comments as $comment){
		?>
		<?php if($comment['media_type']!=''){?>
			<div class="postdata" id="<?=$comment['id']?>">
				<div class="row post">
					<div class="col-xs-12 col-md-4">
						<?php if($comment['media_type']=="image"){?>
						<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/media/<?=$comment['media']?>" alt="profile-img" class="img-responsive" />
						<?}?>
					</div>
					<div class="col-xs-12 col-md-7">
						<h2 class="mid-bar-heading"><?=$comment['firstname'].' '.$comment['lastname'].'('.$comment['social_user'].')'?>&nbsp;&nbsp;&nbsp;&nbsp;Date : <?=date('m/d/Y h:i A', strtotime($comment['date_added']));?></h2>
						<p class="mid-bar-content"><?=$comment['post_desc']?></p>
					</div>
					<div class="col-xs-12 col-md-1">
						<div class="btn-group zapaction">
							<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu" role="menu">
								<li><a href="javascript:void(0)" onclick="reportabuse();">Report/Mark</a></li>
							</ul>
						</div>
					</div>
					<div class="clearfix"></div>
					<div class="col-md-12">
						<a href="javascript:void(0)" class="commentdiv">Comment</a>
					</div>
				</div>
				<div class="row comments" style="display:none;">
					<div class="col-md-12">
						<?php foreach($comment['comment'] as $usercomment){?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $usercomment['photo'] == '' ? DEFAULT_IMG : $usercomment['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<h5 class="media-heading text-primary"><?=$usercomment['firstname']?></h5>
								<p><?=$usercomment['comments']?></p>
								<p class="text-muted"><?=date('m/d/Y h:i A', strtotime($usercomment['comment_date']));?></p>
							</div>
							<span class="glyphicon glyphicon-remove commentremove"></span>
						</div>
						<?}?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $ownzap['photo'] == '' ? DEFAULT_IMG : $ownzap['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<input type="text" class="form-control" name="comment" onkeyup="postcomment(event,this,'<?=$comment['id']?>');" placeholder="Write a Comment....">
							</div>
						</div>
						
					</div>
				</div>
				<hr>
			</div>
			<?}else{?>
			<div class="postdata" id="<?=$comment['id']?>">
				<div class="row post">
					<div class="col-md-11">
						<h2 class="mid-bar-heading"><?=$comment['firstname'].' '.$comment['lastname'].'('.$comment['social_user'].')'?>&nbsp;&nbsp;&nbsp;&nbsp;Date : <?=date('m/d/Y h:i A', strtotime($comment['date_added']));?></h2>
						<p class="mid-bar-content"><?=$comment['post_desc']?></p>
					</div>
					<div class="col-xs-12 col-md-1">
						<div class="btn-group zapaction">
							<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu" role="menu">
								<li><a href="#">Report/Mark</a></li>
							</ul>
						</div>
					</div>
					<div class="clearfix"></div>
					<div class="col-md-12">
						<a href="javascript:void(0)" class="commentdiv">Comment</a>
					</div>
				</div>
				<div class="row comments" style="display:none;">
					<div class="col-md-12">
						<?php foreach($comment['comment'] as $usercomment){?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $usercomment['photo'] == '' ? DEFAULT_IMG : $usercomment['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<h5 class="media-heading text-primary"><?=$usercomment['firstname']?></h5>
								<p><?=$usercomment['comments']?></p>
								<p class="text-muted"><?=date('m/d/Y h:i A', strtotime($usercomment['comment_date']));?></p>
							</div>
							<span class="glyphicon glyphicon-remove commentremove"></span>
						</div>
						<?}?>
						<div class="media">
							<a class="pull-left" href="#">
								<img src="<?php echo base_url(); ?>assets/uploads/.thumbs/images/zap/<?php echo $ownzap['photo'] == '' ? DEFAULT_IMG : $ownzap['photo'] ; ?>" alt="Profile-img" class="media-object" height="32" width="32">
							</a>
							<div class="media-body">
								<input type="text" class="form-control" name="comment" onkeyup="postcomment(event,this,'<?=$comment['id']?>');" placeholder="Write a Comment....">
							</div>
						</div>
						
					</div>
				</div>
				<hr>
			</div>
			<?}?> 
		<?}?>
	<?}?>
</div> 
<script type="text/javascript"><!--
function reportabuse(repres,url)
{
	$.ajax({
		url: 'index.php?route=merchant/profile/reportabuse',
		type: 'post',
		data: {representative :repres,url : url},
		dataType: 'json',
		success: function(json) {
			if (json['success']) {
				$('#notification').html('<div class="success">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
		}
	});
}

function removecomments(id)
{
	if (confirm('Delete cannot be undone! Images will remain on the server. Are you sure you want to do this?'))
	{
		
		$.ajax({
			url: '<?php echo base_url()?>ajax/removecomment/'+id,
						
			success: function(data) {
				if(data=="deleted")
				{
					$('#'+id).fadeOut( "slow" );
				}
			},
			error: function(xhr, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
			}
		});
	}
	else
	{
		return false;
	}
}
$(document).ready(function() {
	$('.commentdiv').click( function() {
		$(this).parent().parent().parent().find('.comments').slideToggle();
	});
	
});
function postcomment(ev,obj,cid)
{
	var comment=obj.value;
	var e = ev || event;
	if(e.keyCode == 13) {
		dataString={ postid: cid, comment: comment };
		$.ajax({
			url: '<?php echo base_url()?>ajax/addcomment',
			data:dataString,
			type: "POST",
			beforeSend: function(){
				
			},
			success: function(data) {
				obj.value="";
				$("#"+cid).find('.comments > div').prepend(data);
				$("#"+cid).find('.comments > div div:first').slideDown("slow");
			},
			error: function(xhr, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
			}
		});
		return false; //prevents form from being submitted.
	}
}
//--></script>	   